package com.dingqb.ktdemo

import com.dingqb.ktdemo.expand.ExpandD
import com.dingqb.ktdemo.expand.exAdd

class Setter {

    var age: Int = 0
        get() = field
        set(value) {
            if (value > 100 || value < 0) field = -1
            else field = value
        }
    var name: String = "tom"
        get() = field
        set(value) {
            if (value == null) {
                field = "";
            } else {
                field = value;
            }
        }

    fun foo() {
        println("foo() \nage = $age ,name==$name")
    }
}

fun main() {
    var setter = Setter()
    setter.foo()
}